package com.example.excelgenera;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Hello {
    public static void main(String[] args) throws IOException {
        final Stream<String> lines = Files.lines(Paths.get("src/data.txt"));
        lines.forEach(v-> System.out.println(v));
    }



    private static class FactorialCalculatingThread extends Thread {
        private BigInteger result = BigInteger.ONE;
        private long num;

        public FactorialCalculatingThread(long num) {
            this.num = num;
        }

        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName() + " has started computing factorial of " + num);
            factorialCalc(num);
            System.out.println(Thread.currentThread().getName() + " is about to exit");
        }


        public void factorialCalc(long num) {
            //Ref: https://www.codespeedy.com/factorial-of-a-large-number-using-biginteger-in-java/
            BigInteger f = new BigInteger("1");
            for (int i = 2; i <= num; i++)
                f = f.multiply(BigInteger.valueOf(i));
            result = f;
        }
        public BigInteger getResult() { return result; }
    }
}
